package com.changanhua.io.file;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * @author changanhua
 */
public class FileDemo {

    private static final String FILE_PATH = "/home/changanhua/Desktop/a.txt";

    private static final String STRING2 = "Hello World\r\n";

    public static void main(String[] args) {
        File file = new File(FILE_PATH);

        try {
            FileOutputStream fileOutputStream = new FileOutputStream(file);
            BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
            for (int i = 0; i < 1000; i++) {
                bufferedOutputStream.write(STRING2.getBytes(StandardCharsets.UTF_8));
            }
            bufferedOutputStream.close();
            /*bufferedOutputStream.flush();*/
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}